/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bitoon.basketdudes.jpa;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author paco
 */
@Entity
@Table(name = "region_zona", catalog = "basketdudes", schema = "central")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RegionZona.findAll", query = "SELECT r FROM RegionZona r"),

    @NamedQuery(name = "RegionZona.findByRegion", query = "SELECT r FROM RegionZona r WHERE r.regionId=:region_id and r.juegoId=:juego_id ORDER BY r.orden "),    
    @NamedQuery(name = "RegionZona.findByJuego", query = "SELECT r FROM RegionZona r WHERE r.juegoId=:juego_id ORDER BY r.orden "),        
    @NamedQuery(name = "RegionZona.findById", query = "SELECT r FROM RegionZona r WHERE r.id = :id")})
public class RegionZona implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
/*
    @Basic(optional = false)
    @Column(name = "zona_id")
    private int zonaId;
*/
    @Basic(optional = false)
    @Column(name = "region_id")
    private int regionId;

    @Basic(optional = false)
    @Column(name = "juego_id")
    private int juegoId;

    @Basic(optional = false)
    @Column(name = "orden")
    private Integer orden;

    @JoinColumn(name = "zona_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Zona zona;
    
    public RegionZona() {
    }

    public RegionZona(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
/*
    public int getZonaId() {
        return zonaId;
    }

    public void setZonaId(int valor) {
        this.zonaId = valor;
    }
*/
  public int getZonaId() {
        return zona.getId();
    }

    public void setZonaId(short valor) {
        this.zona.setId( valor );
    }
      
    
    public Zona getZona() {
        return zona;
    }

    public void setZona(Zona valor) {
        this.zona = valor;
    }
    
    
    public int getRegionId() {
        return regionId;
    }

    public void setRegionId(int region) {
        this.regionId = region;
    }
    
    public int getJuegoId() {
        return juegoId;
    }

    public void setJuegoId(int juego) {
        this.juegoId = juego;
    }

    public int getOrden() {
        return orden;
    }

    public void setOrden(int valor) {
        this.orden = valor;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RegionZona)) {
            return false;
        }
        RegionZona other = (RegionZona) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.tres.jpa.RegionZona[ id=" + id + " ]";
    }
    
}
